#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<vector>
using namespace std;
int search(vector<int>& nums, int target) {
    int left = 0;
    int right = nums.size() - 1;
    int ans = -1;
    while (left <= right)
    {
        int mid = (left + right) / 2;
        if (nums[mid] > target)right = mid-1;
        else if (nums[mid] < target)left = mid+1;
        else return mid;
    }
    return ans;
}
int main()
{
    vector<int>v = { -1,0,3,5,9,12 };

    search(v,2);
    return 0;
}